//
//  ProtocolStrategyPlus.m
//  LearnObjectiveC
//
//  Created by client on 2017/9/11.
//  Copyright © 2017年 吴可高. All rights reserved.
//

#import "ProtocolStrategyPlus.h"

@implementation ProtocolStrategyPlus

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.protocol = self;
    }
    return self;
}

-(int)protocolCalculate:(NSString*)exp;
{
    if (self.protocol && [self.protocol respondsToSelector:@selector(calculate:)]) {
       return  [self.protocol calculate:exp];
    }
    else
    {
        return 0;
    }
}

-(int)calculate:(NSString *)exp
{
    NSArray * items = [self split:exp opt:@"+"];
    return [items[0]intValue] +  [items[1]intValue];
}

@end
